<%@ page contentType="text/html;charset=UTF-8" language="java"%>
<%@ taglib uri="http://java.sun.com/jsp/jstl/core" prefix="c" %>
<%
	String path = request.getContextPath();
	String basePath = request.getScheme() + "://"
			+ request.getServerName() + ":" + request.getServerPort()
			+ path + "/";
%>

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">   
<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en">   								
	<head> 
	    <meta http-equiv="Content-Type" content="text/html; charset=utf-8" />							
		<%@ include file="../jslib/jquerylib.jsp" %>
	    <script type="text/javascript" src="<%=request.getContextPath() %>/jslib/lhgdialog/lhgcore.lhgdialog.min.js?skin=mac"></script>
        <link href="<%=request.getContextPath() %>/web/style/layout.css" type="text/css" rel="stylesheet"/>
        <link rel="stylesheet" href="<%=request.getContextPath() %>/jslib/ztree/css/zTreeStyle/zTreeStyle.css" type="text/css"/>
        <script type="text/javascript" src="<%=request.getContextPath() %>/jslib/ztree/jquery.ztree.core-3.4.js"></script>
        <script type='text/javascript' src="<%=request.getContextPath() %>/jslib/My97DatePicker/WdatePicker.js" defer="defer"></script>
	       <!-- 删除结果信息返回 -->
	    	<c:if test="${requestScope.message!=null}">
				<script type="text/javascript">
	  	 		     alert('<c:out value="${requestScope.message}"></c:out>');
	  	 		     window.close();
	  			</script>
	        </c:if>
	 
	<script type="text/javascript">
	var mobanid = '';
	var ids = '';
	var api = frameElement.api, W = api.opener;
	$(document).ready(function(){
			$("#gridTable").jqGrid({					
					url:'<%=request.getContextPath() %>/auto!queryAnalysisData.action?formid='+${requestScope.formid}+'&byTableValue=${requestScope.byTableValue}&byTableColumn=${requestScope.byTableColumn}&sbtype=${requestScope.sbtype}&columnguolvsql='+encodeURIComponent('${requestScope.columnguolvsql}')+'&temp='+Math.round(Math.random()*10000),
					datatype: "json",
					height: "400",
					width: '1000', 
					colNames:[${requestScope.colName}],
					colModel:[${requestScope.colModel}],
					shrinkToFit:false,
					sortname:'ID',
					sortorder:'desc',
					viewrecords:true,
					multiselect: true, // 是否显示复选框
					multiboxonly : true, 
					//gridview: true,  //提升速度
					rownumbers: true,//显示行号
					rownumWidth: 30, //行号的宽度
					rowNum:<%=session.getAttribute("SYS_PAGECOUNT")%>,
					rowList:[15,20,50,200,500],
					toolbar: [false,"top"],
					jsonReader: {
						root:"rows",		// 数据行（默认为：rows）
						page: "page",  	// 当前页
						total: "total",  // 总页数
						records: "records",  // 总记录数
						repeatitems : false		// 设置成false，在后台设置值的时候，可以乱序。且并非每个值都得设
					},
					prmNames:{rows:"rows",page:"page",sort:"sidx",order:"sord",search:"search"},
					pager:"#gridPager",
					postData : {
		     			columns : "${requestScope.columns}",
		     			tableName:"${formnew.formEnName}"
		     		},
					caption: "${formnew.formCnName}列表"									
			});
				
	}); 
	
	//分析表单
	function analysisData(){
		var ids= $("#gridTable").jqGrid("getGridParam", "selarrrow") + "";
		var arrayIDs = ids.split(',');
		var taskids = "";
		for(var i=0;i<arrayIDs.length;i++){
			var row = jQuery("#gridTable").jqGrid('getRowData',arrayIDs[i]);//获取选中行.
			taskids+=row.flowtaskid+",";
		}
		if (taskids.length>0){
			taskids = taskids.substring(0,taskids.length-1);
		}
		var toUrl = "<%=request.getContextPath() %>/auto!gotoAnalysisView.action?ids="+taskids+"&filemodeid=${filemodeid}&baseinfoid=${requestScope.formid}&tableName=${formnew.formEnName}&${parasContent}queryColumn=${requestScope.queryColumns}";
		$.dialog({
	        title: '数据分析',
			content: 'url:'+ toUrl,
	        okVal: false,//确定按钮文字
	        cancelVal: false,//取消按钮文字
	        min: true, //是否显示最小化按钮
	        max: false,//是否显示最大化按钮
	        fixed: false,//开启静止定位
	        lock: true,//开启锁屏
	        focus: true,//弹出窗口后是否自动获取焦点（4.2.0新增）
	        time: null,//设置对话框显示时间
	        resize: true,//是否允许用户调节尺寸
	        drag: true,//是否允许用户拖动位置
	        cache: false,//是否缓存iframe方式加载的窗口内容页
	        zIndex:W==null?1976:W.$.dialog.setting.zIndex+1,
	        width: '1050px',
	        height: '650px'
		});
	}
	
	//查询
	function gridSearch(){
		var params = {  
			${requestScope.queryValue}
			columns : "${requestScope.columns}",
    			tableName:"${formnew.formEnName}",
    			queryColumn:"${requestScope.queryColumns}",
    			"formid":"${requestScope.formid}",
    			"byTableValue":"${requestScope.byTableValue}",
    			"byTableColumn":"${requestScope.byTableColumn}"
		};
		 var postData = $("#gridTable").jqGrid("getGridParam", "postData");
		 $.extend(postData, params);
		jQuery("#gridTable").jqGrid('setGridParam',
		{
			url:'<%=request.getContextPath() %>/auto!queryAutoData.action?formid='+${requestScope.formid}+'&byTableValue=${requestScope.byTableValue}&byTableColumn=${requestScope.byTableColumn}&sbtype=${requestScope.sbtype}&columnguolvsql='+encodeURIComponent('${requestScope.columnguolvsql}')+'&temp='+Math.round(Math.random()*10000)
			
		}).trigger("reloadGrid", [{page:1}]); 	
    } 

	function chooseItem(){
		var ids= $("#gridTable").jqGrid("getGridParam", "selarrrow") + "";
		if (!ids) {
		    alert("请先选择记录!");  
		    return false;  
		}
		if(ids.indexOf(",")!=-1){
			alert("只能选择一条记录!");  
		    return false; 
		}
		var row = jQuery("#gridTable").jqGrid('getRowData',ids);//获取选中行.
		var id = row.ID; 
		var obj = new Object();
		obj.mubanid = '<%=request.getParameter("mobanid")%>';
		obj.sampleid = id;
		var equipmentIds = window.showModalDialog("<%=basePath%>/task/choose_template_item.jsp?flag=${requestScope.flag}",obj,"dialogWidth=1060px;dialogHeight=550px");
	}
	//选择人员
	function selectperson(id)
	{
		var users = window.showModalDialog("<%=request.getContextPath() %>/user/chooseAllUser.jsp", window, "dialogWidth:1000px;status:no;dialogHeight:500px");
    	if (users != null) {
    		var userIds = [];
            var userNames = [];
            for(var i=0;i<users.length;i++){
                userIds.push(users[i]['userid']);
                userNames.push(users[i]['username']);
            }
            document.getElementById("user_"+id).value = userNames.join();
            //document.getElementById(id).value = userIds.join();
            document.getElementById(id).value = userNames.join();
    	}
	}
	//选择部门
	function selectdept(id)
	{
		var datas = window.showModalDialog("<%=basePath%>/resource/choose/choose_organizationIndex.jsp?temp="+Math.round(Math.random()*10000),'',"dialogWidth=900px;dialogHeight=550px");
		if(typeof(datas) == 'undefined'){
		}else{
			var json1 = eval('(' + datas + ')');
			 document.getElementById("dept_"+id).value = json1.ORG_NAME;
			 document.getElementById(id).value = json1.ORG_ID;
		}
	}
	//选择外键数据信息
	//参数信息：表明，关联列，显示列
	function selectData(id,tablename,colname,disname,cnname){
	    var fileColname ='hideFileName';
	    if(tablename=='DIC_STANDARD'){
	      fileColname = "YCLJS_GYYW";
	    }
		var datas = window.showModalDialog("<%=basePath%>/form/auto_choose_list.jsp?flag=0&tablename="+tablename+"&colname="+colname+"&disname="+disname+"&cnname="+escape(encodeURIComponent(cnname))+"&fileColname="+fileColname+"&temp="+Math.round(Math.random()*10000),'',"dialogWidth=500px;dialogHeight=500px");
		if(typeof(datas) == 'undefined'){
		}else{
			var json1 = eval('(' + datas + ')');
			 document.getElementById("data_"+id).value = json1.NAME;
			 document.getElementById(id).value = json1.ID;
		}
	}
	
	</script>	
	</head>
	<body>
	<form id="jstjForm" name="jstjForm" action="filemodeAction!exportJiShuTiaoJian.action" method="post" >
		<input id="ids" type='hidden' name="ids" />
		<input id="params" type='hidden' name="params"/>
		<input id="filemodeid" type="hidden" name="filemodeid" value="${filemodeid}" />
	</form>
	<form action="" method="post" >
	     ${queryContent }
	    <!-- <table  border='0' cellpadding='6' cellspacing='0' class='tabman' style='margin-bottom:0px'>
	    <tr>
	    <td>试验时间：</td>
	    <td><input type="text" name="starttime" id="starttime" onClick="WdatePicker()" readonly class="search_InputText" style="width:99%;" /></td>
	    <td>至：</td>
	    <td><input type="text" name="endtime" id="endtime" onClick="WdatePicker()" readonly class="search_InputText" style="width:99%;" /></td>
	    </tr></table>
	     -->

		<table style="width: 100%;" class="tableCont">
		  	<tr>
				<td>
				    <input type='button' class='button_b' value='查询' onclick='gridSearch()'/>
				    <input type='button' class='button_b' value='清空' onclick='reset()'/>
				    <input id="search" type='button' value='分 析' onclick='analysisData()' class='button_b' />
				</td>
			 </tr>
			<tr>
				<td colspan="4">
					<table id="gridTable"></table>
					<div id="gridPager"></div>
				</td>
			</tr>
		</table>
		</form>
	</body>
</html>
